<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<div id="root">
    <h2>今天天气很{{weatherInfo}}</h2>
    <button @click="changeWeather">切换天气</button>
    <!--也可以这样写-->
<!--    <button @click="isHot = !isHot">切换天气</button>-->
</div>
</body>
<script type="text/javascript">
    Vue.config.productionTip = false;
    const vm = new Vue({
        el: '#root',
        data() {

            return {
                isHot: true
            }
        },
        methods: {
            changeWeather(e){
                this.isHot = !this.isHot;
            }
        },
        computed: {
            weatherInfo: {
                get() {
                    return (this.isHot ? "炎热" : "凉爽");
                }
            }
        }
    });
</script>
</html>